<?php
class OORDBMySQLConnection extends OORDBConnection
{
	private $connection;
	private $server;
	private $user;
	
	public function __construct( $server, $user, $password )
	{
		$this->connection = mysql_connect( $server, $user, $password );
		$this->server = $server;
		$this->user = $user;
	}
	
	public function getServer()
	{
		return $this->server;
	}
	
	public function getUser()
	{
		return $this->user;
	}
	
	public function getDatabases()
	{
		$query = $this->newSelectQuery();
		$query->setSQL( "SHOW DATABASES" );
		$query->execute();
		$databases = new ArrayObject();
		foreach ( $query as $row )
		{
			$values = array_values($row);
			$databases->append( new OORDBMySQLDatabase( $this, $values[0] ) );
		}
		return $databases->getIterator();
	}
	
	public function newQuery()
	{
		return new OORDBMySQLQuery( $this->connection );
	}
	
	public function newInsertQuery()
	{
		return new OORDBMySQLInsertQuery( $this->connection );
	}
	
	public function newSelectQuery()
	{
		return new OORDBMySQLSelectQuery( $this->connection );
	}
}
?>
